# Flow-IPC: Sessions
# Copyright 2023 Akamai Technologies, Inc.
#
# Licensed under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in
# compliance with the License.  You may obtain a copy
# of the License at
#
#   https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in
# writing, software distributed under the License is
# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
# CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing
# permissions and limitations under the License.

@0xc8f671724349c968; # Manually generated by `capnp id` and saved here for all time.

using Cxx = import "/capnp/c++.capnp";

# The following section is, informally, this schema file's *header*.
# Recommendation: copy-paste relevant pieces into other schema files + follow similar conventions in this
# and other library+API combos.
#
# Header BEGIN ---

# Quick namespace reference:
# - ipc::session: Flow-IPC's ipc::session sub-module.
#   - schema: Indicates the symbols therein are auto-generated by capnp from a schema such as in this file.
$Cxx.namespace("ipc::session::schema");

# --- common.capnp ---
# This schema defines generally applicable types, including structs and aliases, for Flow-IPC users of ipc::session.

# --- END Header.

using ProcessId = Int32; # Matches Linux definition at least.
using UserId = UInt32; # Matches Linux definition at least.
using GroupId = UInt32; # Matches Linux definition at least.

enum MqType
{
  # Type of kernel-persistent message queue (MQ).

  none @0;
  # Sentinel value/no MQ type specified.

  posix @1;
  # POSIX message queues (`man mq_overview`).

  bipc @2;
  # boost.interprocess message queues (boost::interprocess::message_queue, see online docs).

  endSentinel @3;
}

enum ShmType
{
  # Type of kernel-persistent SHM storage; either *none* or one of our ipc::session-supported providers.

  none @0;
  # Sentinel value/no SHM type specified.

  classic @1;
  # SHM provider: ipc::shm::classic::Pool_arena.

  jemalloc @2;
  # SHM provider: ipc::shm::arena_lend::jemalloc.

  endSentinel @3;
}

struct ProcessCredentials
{
  processId @0 :ProcessId;
  userId @1 :UserId;
  groupId @2 :GroupId;
}
